auto.waitFor();//等待无障碍开启
setScreenMetrics(1080, 2160);
//设置静音，最小亮度
我的亮度 = device.getBrightness();//准备一个备用
device.setMusicVolume(0);
device.setBrightness(7);
toastLog("已设置静音、最小亮度")


toastLog("开始运行");
shell("am force-stop com.tencent.qqlive", true);//先用root停止腾讯视频
sleep(1000);
//intent直达签到网址
shell("am start 'intent:#Intent;component=com.tencent.qqlive/.ona.browser.H5Activity;S.reportKey=;S.actionUrl=txvideo%3A%2F%2Fv.qq.com%2FHtml5Activity%3Furl%3Dhttp%253A%252F%252Fv.qq.com%252Fx%252Fbu%252Fmobile_checkin;end'", true);
text("签到").waitFor();//在此等待一下

//textContains("精选").waitFor();//等待界面打开
//intent直达下载界面
shell("am start 'intent:#Intent;component=com.tencent.qqlive/.ona.offline.client.downloading.DownloadingActivity;S.actionUrl=txvideo%3A%2F%2Fv.qq.com%2FDownloadingActivity;end'", true);
text("全部开始").findOne().click();

//在10秒内找出领取
var lq = text("领取").findOne(10000);
if (lq != null) {
    lq.click();
    sleep(5000);
} else {
    toast("没有弹出领取，可能已经领过了");
};

text("全部暂停").findOne().click();
//使用root删除下载缓存,"videos_a3HZw"可能跟我的不一样
shell("rm -rf /storage/emulated/0/Android/data/com.tencent.qqlive/files/videos_a3HZw/*", true);
toastLog("下载任务完成");
//直达视频界面
shell("am start 'intent:#Intent;component=com.tencent.qqlive/.ona.activity.VideoDetailActivity;B.isOffLine=false;S.reportKey=;S.reportParam=;S.actionUrl=txvideo%3A%2F%2Fv.qq.com%2FVideoDetailActivity%3FneedAuthorize%3D1%26textType%3D1%26cover_id%3Drj8uc45tm8a17wm%26userid%3D1842229414%26vid%3Dz0032udy82e%26isSpecial%3D1%26vuserid%3D312126101%26nickname%3D1842229414%26from%3D20475%26userType%3Dqq%26video_id%3Dz0032udy82e%26cid%3Drj8uc45tm8a17wm;B.VideoDetailUniversalStyle=false;end'", true);
bounds(983, 557, 1051, 674).clickable().click();
sleep(1000)
click(2100, 800)
sleep(60)
click(2100, 800)//暂停视频

sleep(500);
click(1800, 1015)
sleep(500);
click(1800, 1015)//这个还是点坐标比较稳
className("EditText").findOne().setText("来了……来了");//发送弹幕的内容
sleep(1000);



var 发送的范围 = text("发送").findOne().bounds();
toastLog(发送的范围)
click(发送的范围.centerX(), 发送的范围.centerY());
toastLog("点击发送")

//在10秒内找出领取
var lq = text("领取").findOne(10000);
//如果找到控件则点击
if (lq != null) {
    lq.click();
    sleep(6000);
} else {
    //否则提示没有找到
    toast("没有找到领取，可能已经领过了");
};

toastLog("弹幕任务已完成");

shell("am force-stop com.tencent.qqlive", true);
shell("am start 'intent:#Intent;component=com.tencent.qqlive/.ona.browser.H5Activity;S.reportKey=userCenter_viplevel_entry;S.actionUrl=txvideo%3A%2F%2Fv.qq.com%2FHtml5Activity%3Furl%3Dhttps%253A%252F%252Ffilm.qq.com%252Fx%252Fautovue%252Fgrade%252F%253Fptag%253DVgrade.card;S.reportParams=;end'", true);
textContains("成长体系").waitFor();
sleep(5000);
toastLog("网页已打开")
textContains("成长明细").waitFor();
toastLog("发现成长明细按钮");
sleep(2000)
text("成长明细").findOne().parent().click();
textContains("积分明细").waitFor();
sleep(5000);//时间不够
toastLog("准备截图");
shell("screencap -p /sdcard/Autojs/txsp.png", true);
sleep(500);

var picurl = sougoupic("/sdcard/Autojs/txsp.png");
var picmd = "![](" + picurl + ")";
serverchan("腾讯视频签到成功", picmd);


device.setBrightness(我的亮度)//恢复亮度

toastLog("任务完成，准备结束");
shell("am force-stop com.tencent.qqlive", true);
toastLog("腾讯视频已停止");








//搜狗图床函数
function sougoupic(file) {
    var url = "https://pic.sogou.com/pic/upload_pic.jsp"
    var res = http.postMultipart(url, {
        file: open(arguments[0])
    });
    var picurl = res.body.string();
    return picurl;//返回图片链接
}

//service酱函数
function serverchan(text, desc) {
    var url = "https://sc.ftqq.com/SCU88922T081d7478a135cf4ffa4a444fb1f823e05e6896265d44f.send";
    var res = http.post(url, {
        "text": arguments[0],
        "desp": arguments[1]
    });
    var msg = res.body.json().errmsg;
    toastLog(msg);
}

exit();